package com.teradata.filter.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

import java.util.ArrayList;
import java.util.List;

//@Component
public class FilterRegistrationConfig {

    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        List<String> urlPatterns = new ArrayList<String>();

        TestFilter testFilter = new TestFilter();   //new过滤器
        ModifyParamtersFilter modifyParamtersFilter = new ModifyParamtersFilter();
        urlPatterns.add("/odata");      //指定需要过滤的url
        filterRegistrationBean.setFilter(testFilter);       //set
        filterRegistrationBean.setFilter(modifyParamtersFilter);
        filterRegistrationBean.setUrlPatterns(urlPatterns);     //set

        return filterRegistrationBean;
    }
}
